package com.gourd.notice.validation.dao;


import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.gourd.notice.validation.entity.VerificationCode;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * @author gourd
 * @date 2018-12-26
 */
@Repository
public interface VerificationCodeDao extends BaseMapper<VerificationCode> {

    /**
     * 获取有效的验证码
     * @param scenes 业务场景，如重置密码，重置邮箱等等
     * @param type
     * @param value
     * @return
     */
    @Select(value = "SELECT code,type,`value`,scenes,id FROM sys_sys_verification_code " +
            "where scenes =#{scenes} AND type =#{type} AND value=#{value}")
    VerificationCode findByScenesAndTypeAndValueAndStatusIsTrue(@Param("scenes") String scenes,
                                                                @Param("type") String type, @Param("value") String value);
}
